import { IPhones } from "../typings";
import { SET_PHONE_LIST, SET_PHONE_LIST_TYPE } from "./actionTypes";

//定义action对象类型
 interface ISetPhoneList{
  type: SET_PHONE_LIST_TYPE,
  payload: IPhones[]
}

//后续还会定义更多的action类型时可以别名联合声明的类型
export type TAction = ISetPhoneList;

/**
 * @description 该函数可以触发更改reducers函数
 * @param phoneList 商品列表数据
 * @returns actions对象
 */
export function setPhoneList(phoneList:IPhones[]): ISetPhoneList {
  return {
    //type必须写,因为需要它去判断后更改state
    type: SET_PHONE_LIST,
    payload: phoneList
  }
}